#include "../Net_h/Net.h"
#include <QAbstractSocket>   //不能直接declare class QAbstractSocket，不然报错

class QTcpSocket;
class NetAsyncImp : public QObject,public Net {
   Q_OBJECT

public:
    NetAsyncImp();

    int Connect(QString ip, QString port);
    bool IsConnected();
    int ReConnect(QString ip, QString port);

    //发送各种类型的数据。。。根据protocol的封包
    int Send(QString content);
    int SendHandShakeMsg();
    int SendMsg();
    int SendHeartMsg();
    int SendPauseMsg();
    int SednPlayMsg();

    //这里需要加入拆包
    QString GetMessage(){return _msgFromServer;}


    void ClearMessage(){_msgFromServer = "";}

    //有消息到来时提醒User
    void InformNewMessage() const{
        emit NewMessageCame();
    }

signals:

    //新消息到来信号
    void NewMessageCame() const;

public slots:
    void ReadError(QAbstractSocket::SocketError);
    void Read();

private:
    QTcpSocket* _socket;
    quint16 _blockSize;
    QString _msgFromServer;



};
